<template>
  <div class="not-found">
    <div class="error-container">
      <h1>404</h1>
      <h2>页面不存在</h2>
      <p>您访问的页面不存在或已被删除</p>
      <el-button type="primary" @click="goHome">返回首页</el-button>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router';
import { useUserStore } from '../store/user';

const router = useRouter();
const userStore = useUserStore();

// 返回首页
const goHome = () => {
  if (userStore.isLoggedIn) {
    router.push(`/${userStore.role}/dashboard`);
  } else {
    router.push('/login');
  }
};
</script>

<style scoped>
.not-found {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f5f7fa;
}

.error-container {
  text-align: center;
  padding: 40px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

h1 {
  font-size: 80px;
  margin: 0;
  color: #409EFF;
}

h2 {
  font-size: 24px;
  margin: 10px 0;
  color: #303133;
}

p {
  color: #606266;
  margin-bottom: 30px;
}
</style> 